package com.szeldon.declatest.eval;

import java.util.Properties;

import com.szeldon.declatest.eval.exceptions.EvaluationException;
import com.szeldon.declatest.exec.AbstractTestsSuiteExecutor;
import com.szeldon.declatest.exec.TestSuiteExecHistory;

/**
 * Interface for plugins for {@link ScenarioPartEvaluator}.
 * 
 * @author szeldon
 * 
 */
public interface IScenarioEvaluatorPlugin {

    /**
     * Returns name of plugin. Name can't contain {@link ScenarioPartEvaluator#PREFIX_SEPARATOR}.
     * 
     * @return
     */
    public abstract String getPluginPrefix();

    /**
     * Evaluates value. Sometimes it's plain string value, but may be some plugin-compatible expression.
     * 
     * @param executor
     *            Executor that can be used to get some data from previously executed steps etc.
     * @param value
     *            Plugin-compatible value to be evaluated.
     * @param history
     *            History of test suite's execution during which this plugin is used.
     * @param properties
     * @throws EvaluationException
     */
    public abstract String evaluateValue(AbstractTestsSuiteExecutor executor, String value, Properties properties,
            TestSuiteExecHistory history) throws EvaluationException;

    /**
     * Evaluates an expression using left and right value and an operator between them.
     * 
     * @param executor
     *            Executor that can be used to get some data from previously executed steps etc.
     * @param leftValue
     *            Left value.
     * @param operator
     *            Plugin-compatible operator.
     * @param rightValue
     *            Right value.
     * @param properties
     * @param history
     *            History of test suite's execution during which this plugin is used.
     * @return Returns true if evaluation ended as true. False otherwise.
     */
    public abstract boolean evaluateOperator(AbstractTestsSuiteExecutor executor, String leftValue, String operator,
            String rightValue, Properties properties, TestSuiteExecHistory history);

}
